<?php
namespace Controller;

use Requests;
use Service\CnfService;
use Service\TestService;
use Yar_Server;
use Yar_Client;


/**
 * RpcController
 * @author los_gsy
 */
class RpcController extends BaseController {
	/**
	 * 初始化
	 */
	public function __construct() {
		parent::__construct();
	}


	/**
	 * test
	 */
	public function test() {
		echo __METHOD__;
	}


	/**
     * yar server
     */
	public function yarServer() {
		$service = new Yar_Server(new TestService);
		$service->handle();
	}


	/**
	 * yar client
	 */
	public function yarClient() {
		$url = 'http://www.mpf.lab/Rpc/yarServer';
		$client = new Yar_Client($url);

		/* call remote service */
		$result = $client->getArr();
		var_dump($result);
	}


	/**
	 * http方式实现的rpc server
	 */
	public function httpServer() {
		echo CnfService::test();
	}


	/**
	 * http方式实现的rpc client
	 */
	public function httpClient() {
		$url = 'http://www.mpf.lab/Rpc/httpServer';
		$resp = Requests::get($url);
		$result = $resp->body;
		var_dump($result);
	}






}
